/*
 * @lc app=leetcode.cn id=26 lang=java
 *
 * [26] 删除有序数组中的重复项
 */

// @lc code=start
class Solution {

    // [0ms, 100%], [42.7MB, 84%]
    public int removeDuplicates(int[] nums) {
        int len = nums.length;
        if (len < 1)
            return 0;
        int tmp = nums[0], result = 1;
        for (int i = 0; i < len; i++) {
            if (nums[i] != tmp) {
                tmp = nums[i];
                nums[result++] = tmp;
            }
        }
        return result;
    }
}
// @lc code=end
